window.onload = function(){
	// 学生端与教师端切换
	let backgrouund ;
	const login = new Vue({
		el:'#manager',
		data:{
			account:'',
			password:''
		},
		methods:{
			isPassword(){
				const newPasswordInput = document.getElementById('Password');
				let reg = /^(?![0-9]*$)(?![A-z]*$)[0-9A-z]{8,16}$/;
				if (reg.test(this.newPassword1)){
					newPasswordInput.style.border = '2px solid green' 
				}else{
					newPasswordInput.style.border = '2px solid red'
				}
			},
			submitClick1(){
				var account = document.getElementById("account").value;
				var password = document.getElementById("Password").value;
				var chekCode = document.getElementById("validateCode1").value;
				var xhttp = new XMLHttpRequest();
				xhttp.onreadystatechange = function() {
					if (xhttp.readyState != 4)
					{
						return;
					}
					var loginInformation = this.getResponseHeader("loginInformation");
					//账号空
					if ("usernameNull" == loginInformation)
					{
						alert(this.responseText);
					}
					//密码空
					else if("passwordNull" == loginInformation)
					{
						alert(this.responseText);
					}
					//验证码空
					else if("checkCodeNull" == loginInformation)
					{
						alert(this.responseText);
					}
					//验证码错误
					else if("checkCodeWrong" == loginInformation)
					{
						alert(this.responseText);
					}
					//账号或密码错误
					else if("permitWrong" == loginInformation)
					{
						alert(this.responseText);
					}
					else
					{

					}

					if (this.getResponseHeader("href") != null)
					{
						window.location.href = this.getResponseHeader("href");
					}
				};
				xhttp.open("post", "/login/SuperLoginServlet?username=" 
				+ account 
				+ "&password=" + password 
				+ "&checkCode=" + chekCode
				, true);
				xhttp.send();
			}
		}
	})
	
	



	const changeValidate = document.getElementById('changeValidate');
	const checkCodeImg = document.getElementById('checkCode');
	const checkCodeDiv = document.getElementById('checkCodeDiv');
	//验证码图片更换
	function changeCheckCode(){
		checkCodeImg.src = "/checkCode?" + new Date().getTime();
	}
	changeValidate.onclick = changeCheckCode;
	checkCodeDiv.onclick = changeCheckCode;
	changeCheckCode();
}
